-
Notifications
You must be signed in to change notification settings - Fork 26
🤖 Fix config array access compatibility issues #274
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Make workspace path access defensive with optional chaining to prevent crashes when switching between branches with different config formats. Changes: - Add optional chaining (?.) to all workspacePath.split() calls - Provide fallbacks using workspaceId when path is undefined - Affects App.tsx and utils/commands/sources.ts This allows the app to work with both: - Old config format (only 'path' field) - New config format (with 'id', 'name', and 'path' fields) Prevents 'Cannot read properties of undefined' errors when config has fields that the current code version doesn't expect.
Don't render AIView if workspacePath is undefined to prevent crashes in features that depend on a valid path (like terminal operations). This ensures we show the welcome screen instead of attempting to render a workspace view with invalid/missing data.
Guard all workspaces array access with ?? [] fallback to prevent crashes when config structure differs between branches. Fixed locations: - App.tsx: config.workspaces.slice() and .find() - ProjectSidebar.tsx: config.workspaces.map() - ipcMain.ts: config.workspaces on findIndex, filter, length, push, array assignment - config.ts: for...of loop over projectConfig.workspaces Each location now handles undefined/missing workspaces arrays gracefully, allowing seamless switching between old and new config formats.
ammario
approved these changes
Oct 16, 2025
Support reading workspace ID from config when present, falling back to generated ID when missing. This allows old code (main branch) to work with new config format (stable-ids branch). Changes: - Workspace interface now has optional id, name, createdAt fields - getAllWorkspaceMetadata() uses stored ID when available - findWorkspace() checks both stored and generated IDs - Workspace rename logic checks both ID formats This fixes the issue where workspaces created on stable-ids branch (with stable IDs like 'f0e1f76700') don't appear when switching to main branch (which expects IDs like 'cmux-f0e1f76700').
When metadata.json doesn't exist (workspaces created on newer branches), reconstruct metadata from config and save it for future use. This fixes resumeStream errors when switching from stable-ids branch (which stores metadata in config) to main branch (which expects metadata.json files). The fallback: 1. Looks up workspace in config via getAllWorkspaceMetadata() 2. Saves the metadata to metadata.json for future access 3. Returns the metadata so the operation can proceed This allows seamless switching between branches with different metadata storage strategies.
Don't check both stored and generated IDs simultaneously - this causes renamed workspaces to still match their old IDs. Instead, use stored ID if present, otherwise fall back to generated ID. This ensures proper separation between old and new workspace identities. Fixes renameWorkspace integration test failure where old workspace ID was still resolving after rename.
The renameWorkspace tests were manually adding workspaces to config after setupWorkspace had already created them via WORKSPACE_CREATE IPC. This created duplicates in config, causing renamed workspaces to still be found by their old IDs. Fixed by removing the redundant manual config manipulation - WORKSPACE_CREATE already handles both project creation and workspace registration. This was causing getAllWorkspaceMetadata() to return duplicate IDs, which made the fallback logic incorrectly find renamed workspaces by their old IDs.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
After PR #273 merged, additional compatibility issues were discovered:
This occurs when
projectConfig.workspacesis undefined due to config format differences between branches.Root Cause
The config loader uses type assertions without validation:
If loaded config has
ProjectConfigwith missingworkspacesfield, all array operations fail.Solution
Add
?? []fallback to all array operations onprojectConfig.workspaces:Files Fixed
App.tsx:
.find()→?? []).find().slice()→?? []).slice()ProjectSidebar.tsx:
.map()→?? []).map()ipcMain.ts:
.push()→ Initialize if undefined first.findIndex()→?? []).findIndex().lengthand.filter()→?? []).lengthand?? []).filter().lengthin error message →?? []).lengthconfig.ts:
for...ofloop →?? [])Testing
make typecheckpassesmake static-checkpassesImpact
Prevents all
.slice(),.map(),.filter(),.find(),.lengthcrashes when switching between branches with different config formats.